<?php defined('SYSPATH') or die('No direct script access.');

/**
 * Created by PhpStorm.
 * Author: netman
* Time: 2023/10/18
 * Desc: 全局搜索
 */
class Controller_Pc_Api_V2_Search extends Controller_Pc_Api_V2_Base
{

    // 数据请求结果
    private $result;

    /**
     * 参数验证对象
     * @var Request_Api_V2_Search
     */
    private $validation;
    /**
     * 服务
     * @var Service_Api_Search
     */
    private $service;

    public function before()
    {
        parent::before();
        $this->result = array(
            'status' => true,
            'msg' => '操作成功',
            'data' => array()
        );
        $this->validation = Request_Api_V2_Factory::create('search', $this->request_params);
        $this->service = new Service_Api_Search();

    }
    public function after()
    {
        $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
    }
    /**
     * 全局搜索基础配置
     */
    public function action_search_config()
    {
        try {
            $this->validation->search_config()->check();
            $data = $this->service->search_config($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 搜索更多
     */
    public function action_search_more()
    {
        try {
            $this->validation->search_more()->check();
            $this->request_params['platform_no']=$this->platform_no;
            $data = $this->service->search_more($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }


}